package com.pajk.user.exception;

/**
 * 积分业务错误码
 *
 */
public enum CreditErrorEnum {

    OVER_TIMES("OVER_TIMES", "超出给积分的频率"),
    CREDIT_NUM_ERROR("CREDIT_NUM_ERROR","积分值小于0"),
    CREDIT_REMAINING_ERROR("CREDIT_REMAINING_ERROR","积分余额不足")
    ;

    /** 错误码 */
    private String errorCode;

    /** 错误信息 */
    private String errorMessage;

    /**
     * Getter method for property <tt>errorCode</tt>.
     *
     * @return property value of errorCode
     */
    public String getErrorCode() {
        return errorCode;
    }

    private CreditErrorEnum(String errorCode, String errorMessage) {
        this.errorCode = errorCode;
        this.errorMessage = errorMessage;
    }

    public static CreditErrorEnum getByCode(String errorCode) {
        CreditErrorEnum[] values = CreditErrorEnum.values();
        for (CreditErrorEnum value : values) {
            if (value.getErrorCode().equals(errorCode)) {
                return value;
            }
        }
        return null;
    }

    public void setErrorCode(String errorCode) {
        this.errorCode = errorCode;
    }

    public String getErrorMessage() {
        return errorMessage;
    }

    public void setErrorMessage(String errorMessage) {
        this.errorMessage = errorMessage;
    }

}
